const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Geocode = sequelize.define('Geocode', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  address: {
    type: DataTypes.STRING(255),
    allowNull: true,
    comment: '地址'
  },
  location: {
    type: DataTypes.STRING(50),
    allowNull: true,
    comment: '坐标位置'
  },
  type: {
    type: DataTypes.ENUM('geo', 'regeo'),
    allowNull: false,
    comment: '编码类型：geo-地理编码，regeo-逆地理编码'
  },
  province: {
    type: DataTypes.STRING(100),
    allowNull: true,
    comment: '省份'
  },
  city: {
    type: DataTypes.STRING(100),
    allowNull: true,
    comment: '城市'
  },
  district: {
    type: DataTypes.STRING(100),
    allowNull: true,
    comment: '区县'
  },
  street: {
    type: DataTypes.STRING(100),
    allowNull: true,
    comment: '街道'
  },
  number: {
    type: DataTypes.STRING(50),
    allowNull: true,
    comment: '门牌号'
  },
  formatted_address: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '格式化地址'
  },
  adcode: {
    type: DataTypes.STRING(20),
    allowNull: true,
    comment: '行政区划代码'
  },
  level: {
    type: DataTypes.STRING(20),
    allowNull: true,
    comment: '匹配级别'
  }
}, {
  tableName: 'geocode',
  comment: '地理编码表'
});

module.exports = Geocode; 